from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class Test:
    def __init__(self):
        # 打开游览器
        self.driver = webdriver.Chrome()
        # 打开360网页
        self.driver.get('https://www.so.com')

    def search(self,content):
        # 输入搜索关键字点击搜索
        self.driver.find_element(By.ID,'input').send_keys(content)
        self.driver.find_element(By.ID,'search-button').click()

    def quit(self,seconds=2):
        # 关闭游览器
        time.sleep(seconds)
        self.driver.quit()

if __name__ == '__main__':
    t = Test()
    t.search('天气预报')
    t.quit(3)